//
//  VBWelcomeViewController.swift
//  VBo
//
//  Created by 赵世得 on 2016/10/31.
//  Copyright © 2016年 Zh. All rights reserved.
//

import UIKit
import SDWebImage
class VBWelcomeViewController: UIViewController {
    override func loadView() {
        view = bgImageView
    }
    
    override func viewDidAppear(_ animated: Bool) {
        super.viewDidAppear(animated)
        self.headImageView.snp_updateConstraints { (make) in
            make.top.equalTo(self.view).offset(100)
        }
        UIView.animate(withDuration: 1, delay: 1, usingSpringWithDamping: 0.7, initialSpringVelocity: 0, options: [], animations: {
            self.view.layoutIfNeeded()
            }) { (_) in
                UIView.animate(withDuration: 0.25, animations: { 
                    self.messageLabel.alpha = 1
                    }, completion: { (_) in
                        NotificationCenter.default.post(name: NSNotification.Name(VBWeleomeNSNotification), object: "welcomeVC")
                })
        }
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()
        setUpUI()
    }
    private func setUpUI(){
        view.addSubview(headImageView)
        view.addSubview(messageLabel)
        headImageView.snp_makeConstraints { (make) in
            make.size.equalTo(CGSize(width: 90, height: 90))
            make.centerX.equalTo(view)
            make.top.equalTo(view).offset(400)
        }
        messageLabel.snp_makeConstraints { (make) in
            make.centerX.equalTo(view)
            make.top.equalTo(headImageView.snp_bottom).offset(16)
        }
    }
    private lazy var bgImageView: UIImageView = UIImageView(image: UIImage(named: "ad_background"))
    private lazy var headImageView: UIImageView = {
        let img = UIImageView()
        img.layer.borderColor = VBTHEMECOLOR.cgColor
        img.layer.borderWidth = 1
        img.layer.cornerRadius = 45
        img.layer.masksToBounds = true
        img.vb_setImg(withUrlString: VBUserAccountViewModel.sharedTools.userAccountModel?.avatar_large, placeholderImgName: "avatar_default_big")
        return img
        
    }()
    private lazy var messageLabel: UILabel = {
        let lab = UILabel(text: "欢迎回来", font: 18, textColor: VBTHEMECOLOR)
        lab.textAlignment = .center
        lab.alpha = 0
        return lab
    }()
}
